package com.bitdf.txing.common.entity;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.bitdf.txing.common.valid.SaveGroup;
import com.bitdf.txing.common.valid.UpdateGroup;
import com.lemon.util.anno.MysqlColumn;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;
import java.io.Serializable;
import java.util.Date;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class BaseEntity implements Serializable {
    /**
     * 实体状态正常
     **/
    public static final String STATUS_NORMAL = "0";
    /**
     * 实体状态删除
     **/
    public static final String STATUS_DELETE = "1";
    /**
     * 实体状态禁用
     **/
    public static final String STATUS_DISABLED = "2";

    /**
     * 主键id
     */
    @TableId(value = "id",
            type = IdType.ASSIGN_ID
    )
    @NotNull(message = "id不得为空", groups = {UpdateGroup.class})
    @Null(message = "id必须为空", groups = {SaveGroup.class})
    private Long id;
    /**
     * 状态（0正常  2停用 3冻结）
     */
    @MysqlColumn(defaultValue = "0", comment = "状态（0正常  2停用 3冻结）")
    private Integer status;
    /**
     * 删除状态（0正常 1删除 ）
     */
    @MysqlColumn(defaultValue = "0", comment = "删除状态（0正常 1删除 ）")
    @Null(groups = {SaveGroup.class, UpdateGroup.class})
    private Integer isDeleted;
    /**
     * 创建者
     */
    @TableField(fill = FieldFill.INSERT)
    @MysqlColumn(comment = "创建人")
    @Null(groups = {SaveGroup.class, UpdateGroup.class})
    private String createBy;

    /**
     * 创建时间
     */
    @MysqlColumn(comment = "创建时间")
    @TableField(fill = FieldFill.INSERT)
    @Null(groups = {SaveGroup.class, UpdateGroup.class})
    private Date createTime;

    /**
     * 更新者
     */
    @MysqlColumn(comment = "修改人")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    @Null(groups = {SaveGroup.class, UpdateGroup.class})
    private String updateBy;

    /**
     * 更新时间
     */
    @MysqlColumn(comment = "修改时间")
    @TableField(fill = FieldFill.INSERT_UPDATE)
    @Null(groups = {SaveGroup.class, UpdateGroup.class})
    private Date updateTime;
}

